﻿/*
 * Name:        Spawn class
 * Description: An entity that acts as a spawn point
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Gyvate.Util;
using Gyvate.Worldspawn;

namespace Gyvate.Entities
{
    internal class Spawn : BaseEntity
    {
        private int m_rotation = 0;

        public int GetRotation() { return m_rotation; }

        public Spawn(Game game, Vector2d pos, int rotation = 0)
            : base(pos, game)
        {
            /*
             * This doesn't look good, but time is running out, and I don't feel like adding sprite sheets
             */
            switch (rotation)
            {
                case 0:
                default:
                case 360:
                    if (!m_game.IsPrecached(Constants.SPRITE_SPAWN))
                        m_game.PrecacheSprite(Constants.SPRITE_SPAWN);

                    if (!m_game.IsPrecached(Constants.SPRITE_BLOCKED))
                        m_game.PrecacheSprite(Constants.SPRITE_BLOCKED);

                    this.SetSprite(Constants.SPRITE_SPAWN);
                    m_tile = TileList.TILE_SNAKESPAWN;
                    break;

                case 90:
                    m_rotation = 90;
                    if (!m_game.IsPrecached(Constants.SPRITE_SPAWN_90))
                        m_game.PrecacheSprite(Constants.SPRITE_SPAWN_90);

                    if (!m_game.IsPrecached(Constants.SPRITE_BLOCKED))
                        m_game.PrecacheSprite(Constants.SPRITE_BLOCKED);

                    this.SetSprite(Constants.SPRITE_SPAWN_90);
                    m_tile = TileList.TILE_SNAKESPAWN_90;
                    break;

                case 180:
                    m_rotation = 180;

                    if (!m_game.IsPrecached(Constants.SPRITE_SPAWN_180))
                        m_game.PrecacheSprite(Constants.SPRITE_SPAWN_180);

                    if (!m_game.IsPrecached(Constants.SPRITE_BLOCKED))
                        m_game.PrecacheSprite(Constants.SPRITE_BLOCKED);

                    this.SetSprite(Constants.SPRITE_SPAWN_180);
                    m_tile = TileList.TILE_SNAKESPAWN_180;
                    break;

                case 270:
                    m_rotation = 270;
                    if (!m_game.IsPrecached(Constants.SPRITE_SPAWN_270))
                        m_game.PrecacheSprite(Constants.SPRITE_SPAWN_270);

                    if (!m_game.IsPrecached(Constants.SPRITE_BLOCKED))
                        m_game.PrecacheSprite(Constants.SPRITE_BLOCKED);

                    this.SetSprite(Constants.SPRITE_SPAWN_270);
                    m_tile = TileList.TILE_SNAKESPAWN_270;
                    break;
            }
        }
    }
}
